<template>
  <div class="main">
    <!-- 头部导航栏 -->
    <head-component
      :noBack="false"
      title="网贷资料包"/>
    <div class="wangdai">
      <div class="con_list" @click="toDetails(item.id, item.news_title)" v-for="(item, index) in ghList" :key="index">
        <div class="list_num">{{index+1}}.</div>
        <div class="list_name f30">{{item.news_title}}</div>
        <img class="list_right" src="@/common/icon/user/next.png" alt="">
      </div>
    </div>
  </div>
</template>

<script>
import headComponent from '@/components/layout/head'
export default {
    name: "ganhuo.vue",
    data() {
      return {
        ghList:[],
        userStatus: ''
      }
    },
  created() {
    this.getList()
    //  个人信息
    var data2 = {u_id: localStorage.getItem('uid'),token:localStorage.getItem('token')};
    this.$axios.post('index.php?m=user&c=index',data2)
      .then((res) => {
        if(res.data.code == 1){
          this.userStatus = res.data.user.m_level;
        }else{
          this.$router.push('/login');
        }
      });
  },
  methods:{
    getList(){
      var $this = this;
      $this.isVip = localStorage.getItem("isVip");
      var t = this.$toast.loading({message: '正在加载数据', mask: true, duration: 9999})
      var data = {u_id: localStorage.getItem('uid'), token: localStorage.getItem('token')};
      $this.$axios.post('index.php?m=index&c=consult', data)
        .then((res) => {
          t.clear();
          if (res.data.code == 1) {
            res.data.news.map((item, index) => {
              if(item.c_id == 16){
                let obj={
                  c_id: item.c_id,
                  id: item.id,
                  news_addtime: item.news_addtime,
                  news_content: item.news_content,
                  news_img: item.news_img,
                  news_looks: item.news_looks,
                  news_title: item.news_title,
                  news_tui: item.news_tui,
                  news_type: item.news_type
                }
                $this.ghList.push(obj)
              }
            })
          } else {
            $this.$router.push('/login');
          }
        });
    },
    toDetails(id, title){
      var $this = this;
      if($this.userStatus != 0){
        this.$router.push(`/ziliaoDetails?name=${title}&&id=${id}`)
      }else{
        $this.$toast({
          message: '请先开通VIP',
          duration: 800,
          onClose: ()=> {
            $this.$router.push('/vip');
          }
        })
      }
    }
  },
  components: {
    headComponent,
  },
}
</script>
<style scoped lang="less">
  .wangdai{
    margin-top: 1.2rem;
    padding: 0.2rem 0.6rem;
    border-top: 0.02rem solid #f5f5f5;
    .con_list{
      height: 1.2rem;
      display: flex;
      display: -webkit-flex;
      justify-content: space-between;
      -webkit-justify-content: space-between;
      align-items: center;
      -webkit-align-items: center;
      border-bottom: 1Px solid #f5f5f5;
      margin-top: 0.2rem;
      .list_name{ flex: 1; -webkit-flex: 1; margin-left: 0.2rem; }
      .list_right{ height: 0.38rem }
    }
  }
</style>

